package modelLayer;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Sale implements Comparable<Sale>{
	private static int idIterator;
	private int id;
	private int amount;
	private Date date; 
	private DateFormat dFormat;
	
	public Sale(int amount){
		idIterator++;
		this.id = idIterator;
		this.amount = amount;
		dFormat = new SimpleDateFormat("dd/MM/yyyy");
		date = new Date();
	}
	
	public Sale(int id, int amount, Date date){
		idIterator++;
		this.id = id;
		this.amount = amount;
		dFormat = new SimpleDateFormat("dd/MM/yyyy");
		this.date = date;
	}

	public int getId() {
		return id;
	}

	public int getAmount() {
		return amount;
	}
	
	public void addToAmount(int amount){
		this.amount += amount;
	}

	public String getDate() {
		return dFormat.format(date);
	}
	
	public Date getRealDate(){
		return date;
	}
	
	public int compareTo(Sale o){
	    return getRealDate().compareTo(o.getRealDate());
	}

}
